export const parseUserMsg = (data) => {
    const obj = JSON.parse(data);
    const idNum = obj.IDNum;
    let birthday = "";
    if (idNum && idNum.length === 18) {
        // 提取出生年月日（格式：YYYY-MM-DD）
        const year = idNum.substring(6, 10);
        const month = idNum.substring(10, 12);
        const day = idNum.substring(12, 14);
        birthday = `${year}-${month}-${day}`;
    }
    const name = obj.Name;
    const gender = obj.Gender; // 如果Gender为空，可以根据身份证号判断性别
    let genderInfo = gender;
    if (!gender && idNum && idNum.length === 18) {
        // 身份证第17位为奇数表示男，偶数表示女
        const genderCode = parseInt(idNum.charAt(16), 10);
        genderInfo = genderCode % 2 === 1 ? "男" : "女";
    }
    return {
        name,
        sex: genderInfo,
        birthday,
        idNo: idNum,
        cardNo: data,
    };
}